<template>
  <div class="app-container">
    <h2>用户管理</h2>
    
    <el-card>
      <el-form :inline="true" class="search-form">
        <el-form-item label="用户名">
          <el-input v-model="searchForm.username" placeholder="请输入用户名" />
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="searchForm.status" placeholder="请选择状态">
            <el-option label="全部" value="" />
            <el-option label="启用" value="1" />
            <el-option label="禁用" value="0" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
      
      <div class="toolbar">
        <el-button type="primary">新增用户</el-button>
        <el-button type="danger">批量删除</el-button>
      </div>
      
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="username" label="用户名" />
        <el-table-column prop="name" label="姓名" />
        <el-table-column prop="phone" label="手机号" />
        <el-table-column prop="role" label="角色" />
        <el-table-column prop="status" label="状态">
          <template #default="{ row }">
            <el-tag :type="row.status ? 'success' : 'danger'">
              {{ row.status ? '启用' : '禁用' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template #default>
            <el-button link type="primary" size="small">编辑</el-button>
            <el-button link type="danger" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <div class="pagination-container">
        <el-pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="100"
        />
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'

// 搜索表单
const searchForm = reactive({
  username: '',
  status: ''
})

// 表格数据
const tableData = ref([
  {
    id: 1,
    username: 'admin',
    name: '管理员',
    phone: '13800138000',
    role: '超级管理员',
    status: 1
  },
  {
    id: 2,
    username: 'test',
    name: '测试用户',
    phone: '13800138001',
    role: '普通用户',
    status: 1
  },
  {
    id: 3,
    username: 'user01',
    name: '张三',
    phone: '13800138002',
    role: '普通用户',
    status: 0
  },
  {
    id: 4,
    username: 'user02',
    name: '李四',
    phone: '13800138003',
    role: '普通用户',
    status: 1
  }
])
</script>

<style scoped>
.app-container {
  width: 100%;
  padding: 10px;
}

.search-form {
  margin-bottom: 20px;
}

.toolbar {
  margin-bottom: 20px;
}

.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style> 